package com.tentinet.testtapsviewpager.adapter;

import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;
import java.util.ArrayList;
/**
 * <h3>Description</h3>
 * TODO
 * <h3>Author</h3>
 * <h3>Date</h3> 2016/1/25 14:27
 * <h3>Copyright</h3> Copyright (c)2016 Shenzhen Tentinet Technology Co., Ltd. Inc. All rights reserved.
 */
public class ContentViewPagerAdapter extends FragmentPagerAdapter {
    private ArrayList<String> tabList;
    private ArrayList<Fragment> fragments;

    public ContentViewPagerAdapter(FragmentManager fm, ArrayList<String> tabList, ArrayList<Fragment> fragments) {
        super(fm);
        this.tabList = tabList;
        this.fragments = fragments;
    }
    @Override
    public Fragment getItem(int position) {
        return fragments == null ? null : fragments.get(position);
    }
    @Override
    public int getCount() {
        return fragments == null ? 0 : fragments.size();
    }

    @Override
    public CharSequence getPageTitle(int position) {
        return (tabList == null) || (tabList.size()== 0) ||(tabList.size() <= position)|| (tabList.get(position) == null) ? null : tabList.get(position) ;
    }
}
